Turn off shared library signature check for autoconf checks - #27470
Conversation
`AC_CHECK_LIB(somelib, func)` writes the following to conftest.c:
```C
char func ();
int main(void) {
return func ();
}
```
Then runs `emcc conftest.c -lsomelib` and checks whether it succeeds. With
static libraries the signature mismatch is just a warning but with shared
libraries it is a hard error. Before emcc 6.0.0, even if configure tried to make
a shared library it would make a fake dynamic library instead and we didn't see
this problem. But since then it makes a real dynamic library and then fails to
configure.
The fix is if we are configuring pass `-Wl,--no-shlib-sigcheck` to disable the
signature check.
emscripten-core/emscripten#27470 AC_CHECK_LIB(somelib, func)` writes the following to conftest.c: ```C char func (); int main(void) { return func (); } ``` Then runs `emcc conftest.c -lsomelib` and checks whether it succeeds. With static libraries the signature mismatch is just a warning but with shared libraries it is a hard error. Before emcc 6.0.0, even if configure tried to make a shared library it would make a fake dynamic library instead and we didn't see this problem. But since then it makes a real dynamic library and then fails to configure. The fix is if we are configuring pass `-Wl,--no-shlib-sigcheck` to disable the signature check.
| # comes from an object file or an archive lld only warns about the | ||
| # resulting signature mismatch and synthesizes a thunk, but when it comes | ||
| # from a shared library the mismatch is a hard error. This turns off the | ||
| # shared library check. |
There was a problem hiding this comment.
I think the comment comment above on line 889 is already describing the issue.
Maybe we can just say "For the same reason, we need to disable signature check for shared library symbols."?
Its kind of strange to me that static signature checks would be a warning but not shared signature checks would be an error? I believe the reason static signature checks are only a warning by default is precisely to allow for autoconf/cmake games like this. If that is true then the same logic should apply for shared libraries.
Perhaps if we are going to land this we should add a TOTO with a link to and llvm bug to consider changing the default?
There was a problem hiding this comment.
Maybe we can just say "For the same reason, we need to disable signature check for shared library symbols."?
The reason given above is "autoconf declares functions without their proper signatures" which is barely longer than "For the same reason" so I just repeated the whole phrase for clarity.
sbc100
left a comment
There was a problem hiding this comment.
Thanks for working on this!
sbc100
left a comment
There was a problem hiding this comment.
Ok, I'm happy to land this and look into considering way to improve the upstream behaviour separately.
|
Oh this merged without my comment change (I failed to push because the pre-push hook looked for ruff). If you like I can shorten the comment in a followup. |
|
I made an llvm issue: |
AC_CHECK_LIB(somelib, func)writes the following to conftest.c:Then runs
emcc conftest.c -lsomeliband checks whether it succeeds. With static libraries the signature mismatch is just a warning but with shared libraries it is a hard error. Before emcc 6.0.0, even if configure tried to make a shared library it would make a fake dynamic library instead and we didn't see this problem. But since then it makes a real dynamic library and then fails to configure.The fix is if we are configuring pass
-Wl,--no-shlib-sigcheckto disable the signature check.